@extends('admin.frame_layout')
<?php $top_selected = "会员管理";$page_menu = "会员树状图" ?>

@section('head')
    <link rel="stylesheet" href="{{ asset('zTree/css/zTreeStyle/zTreeStyle.css') }}" type="text/css">
@endsection

@section('content')
    <div class="formbody">
        <div class="formtitle"><span>会员推荐关系图</span></div>
        <div class="center-block">

            <div class="content_wrap">
                <div class="zTreeDemoBackground left">
                    <ul id="treeDemo" class="ztree"></ul>
                </div>
            </div>

        </div>
    </div>
@endsection

@section('footer')
    <script type="text/javascript" src="{{ asset('zTree/js/jquery-1.4.4.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('zTree/js/jquery.ztree.core.js') }}"></script>
    <script type="text/javascript">

        var setting = {
            data: {
                key: {
                    title: "t"
                },
                simpleData: {
                    enable: true
                }
            }
        };

        var str = '{!!  $user !!}';
        var obj = eval(str);
        var zNodes = [];

        for (var i in obj) {
            zNodes.push({
                id: obj[i].id,
                pId: obj[i].pid,
                name: obj[i].username,
                t: 'ID: ' + obj[i].id,
                icon: "{{asset('admin/imgs/default_head.jpg')}}",
                open: true,
            });
        }

        $(document).ready(function () {
            $.fn.zTree.init($("#treeDemo"), setting, zNodes);
        });
    </script>
@endsection